class ArticleSnapshotsController < ApplicationController
  before_action :authenticate?
  before_action only: [:show, :update] do
    @article_snapshot = ArticleSnapshot.find(params[:id])
    render root_path unless @article_snapshot
  end

  def show
    article = @article_snapshot.article
    @diff = ::Diff.new(article.content, @article_snapshot.content).diff
  end

  def update
    article = article_snapshot.article
    if article.update_attributes(content: article_snapshot.content)
      redirect_to article_url(article)
    end
  end
end
